package com.example.mobiledestroy;


import com.example.mobiledestroy.util.KeyFilter;
import com.example.mobiledestroy.util.MD5;
import com.example.mobiledestroy.util.SMSService;
import com.example.mobiledestroy.view.TitleBarLayout;

import android.app.Activity;
import android.content.ContentResolver;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.provider.CallLog;
import android.provider.ContactsContract;
import android.provider.ContactsContract.Contacts;
import android.provider.MediaStore;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;

public class BindActivity extends Activity {

	private EditText bindNumEdit;
	private String mobilenum;
	private TitleBarLayout tbl;
	

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_bind);
		
		init();
		
	}
	
	private class CheckListener implements OnClickListener {

        @Override
        public void onClick(View v) {
        	mobilenum = new MD5(bindNumEdit.getText().toString()).getMD5String();
			//开启服务
			Intent a = new Intent(BindActivity.this,SMSService.class);
			startService(a);
			//将绑定号码保存
			SharedPreferences sp = getSharedPreferences("bind_num", MODE_PRIVATE);
			Editor edit = sp.edit();
            edit.putString("mobile_num",mobilenum);
            edit.commit();

            finish();
        }
    }

	private void init() {
		bindNumEdit = (EditText)findViewById(R.id.bind_num);
		tbl = (TitleBarLayout) findViewById(R.id.title_bar);
		tbl.setButtonVisible();
		tbl.setButtonClicker(new CheckListener());
		tbl.setText("请绑定可信手机号");
		
	}
}
